import React ,{Component} from 'react';
import './cList.css';


export default class Clist extends Component {
    constructor(props){
        super(props);
        this.state={}
    };
  
    


    seleCity=(name)=>{
      if(name){
        this.props.onChangeCity(name);
      }
    };
    componentDidMount=function(){

    }

    render (){
        let propsData = this.props.cityList;
        return (
            <div>
                {
                    Object.keys(propsData).map(key => {
                         return <div className="c_item" key={key}>
                                <div className="c_title" data-ref={key} ref={key => {this.ele = key}}>{key}</div>
                                <div className="c_citys_sum">
                                {
                                    propsData[key].map((item,i)=>{
                                       return  <div key={item.id} className="c_citys_list" onClick={this.seleCity.bind(this,item.name)}>{item.name}</div>
                                    })
                                }
                                </div>
                       </div>
                    })
                }
                
            </div>
        )
    }
}